package com.zzyl.controller.customer;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.controller.BaseController;
import com.zzyl.dto.WxLoginDto;
import com.zzyl.service.CustomerService;
import com.zzyl.vo.LoginVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/customer")
@Api(tags = "微信小程序登录")
public class CustomerLoginController extends BaseController {
    @Autowired
    private CustomerService customerService;

    /**
     * 小程序登录
     *
     * @param wxLoginDto
     * @return
     */
    @ApiOperation("小程序登录")
    @PostMapping("/user/login")
    public ResponseResult<LoginVo> login(@RequestBody WxLoginDto wxLoginDto) {
        LoginVo vo = customerService.login(wxLoginDto);
        return success(vo);
    }

    /**
     * 分页查询护理项目列表
     */
    @ApiOperation("分页查询护理项目")
    @GetMapping("/orders/project/page")
    public ResponseResult<PageResponse<NursingProjectVo>> selectPage(@ApiParam(value = "护理项目名称") String name,
                                                                     @ApiParam(value = "当前页") @RequestParam(defaultValue = "1") Integer pageNum,
                                                                     @ApiParam(value = "每页显示记录数") @RequestParam(defaultValue = "10") Integer pageSize,
                                                                     @ApiParam(value = "状态") Integer status) {
        PageResponse<NursingProjectVo> response = customerService.getInfo(name, pageNum, pageSize, status);
        return success(response);

    }

    /**
     * 根据id查询护理项目
     */
    @ApiOperation("根据id查询护理项目")
    @GetMapping("/orders/project/{id}")
    public ResponseResult<PageResponse<NursingProjectVo>> getById(@PathVariable Integer id) {
        NursingProjectVo nursingProjectVo = customerService.getById(id);
        return success(nursingProjectVo);
    }

}

